package com.hibernate.testSet;

import java.util.HashSet;
import java.util.Set;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.hibernate.utils.HibernateFactory;

public class test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
	Speaker1 s1 = new Speaker1();
	s1.setName("kobe");
	Speaker1 s2 = new Speaker1();
	s2.setName("mcgrady");
	Event1 e1 = new Event1();
	Set set1 = new HashSet();
	set1.add(s2);
	set1.add(s2);
	e1.setSpeakers(set1);
	
	
	HibernateFactory.buildSessionFactory();
	Session s = HibernateFactory.openSession();
    Transaction tx = s.beginTransaction();
    try {
    	s.save(e1);
    	s.save(s1);
    	s.save(s2);
    	s.flush();
    	tx.commit();
		
	} finally{
		if(s!=null)
			s.close();
	}
	}

}
